#!/usr/bin/env python
# -*- mode: python; coding: utf-8; -*-
##--------------------------------------------------------------------------##
##
## Copyright (C) 1998-2003 Markus Oberhumer <markus@oberhumer.com>
## Copyright (C) 2003 Mt. Hood Playing Card Co.
## Copyright (C) 2005-2010 Skomoroh <skomoroh@users.sourceforge.net>
## Copyright (C) 2010-2013 Jeremy Austin-Bardo <tjaustinbardo@gmail.com>
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program.  If not, see <http://www.gnu.org/licenses/>.
##
##-- G17 -- S00 ------------------------------------------------------------##
__all__ = []

from .. import formlib as layout
from .. import pilelib as stack
from .. import quickplayscore as quickplay
from ..forms import gypsy as GypsyLayout
from ..gamelib import info as gi, game
from ..hint import CautiousDefaultHint
from ..packlib import info as cs
from ..piles import spider
from ..utillib.misc import kwdefault

GT, SL = gi.GT, gi.SL
Wrap = stack.StackWrapper


class DoubleKlondike(game.Game):
    """
    Finish cards on _foundation_ without limit turn.

    _row_
      Pile 9 horz N. Init deal [1, 2, 3, 4, 5, 6, 7, 8, 9] card. Build
      down in rank by alt color. Play seq. Base KING.

    _talon_
      Pile 1 SE. Deal 1 card on _waste_.

    _waste_
      Pile 1 W _talon_. Build none. Play top.

    _foundation_
      Pile 8 horz S. Build up in rank by same suit. Play top.
    ------
    :cvar Layout _layout_: layout.HarpLayout
    :cvar Stack _talon_: stack.WasteTalon (max_rounds=INFINITE)
    :cvar Stack _waste_: stack.WasteStack
    :cvar Stack _foundation_: stack.SS_Foundation
    :cvar Stack _row_: stack.AC_RowStack (base_rank=KING)
    :cvar Hint _hint_: hint.DefaultHint
    """
    __info__ = dict(id=21, name='Double Klondike', game_type=GT.KLONDIKE,
                    decks=2, redeals=cs.INFINITE, skill_level=SL.BALANCED,
                    version='2.90', altnames=('Klondike (2 Decks)',))
    __author__ = 'Markus Oberhumer'
    __version__ = 7.70

    _layout_ = layout.HarpLayout
    _talon_ = Wrap(stack.WasteTalon, max_rounds=cs.INFINITE)
    _waste_ = stack.WasteStack
    _foundation_ = stack.SS_Foundation
    _row_ = Wrap(stack.AC_RowStack, base_rank=cs.KING)

    def _create_game(self, **kw):
        kwdefault(kw, rows=9, texts=True, playcards=19)
        return super(DoubleKlondike, self)._create_game(**kw)

    def _start(self, flip=False, reverse=True, **kw):
        """
        Deal initial cards for new game.
          - s[rows] 1..LEN ea top.

        .. \_start([flip=False, reverse=True]) -> None
        """
        for i in range(1, len(self.s['rows'])):
            self.s['talon'].dealRow(rows=self.s['rows'][i:], flip=flip,
                                    reverse=reverse, frames=0)
        self.s['talon'].dealRow(reverse=reverse)


class DoubleKlondikeByThrees(DoubleKlondike):
    """
    Finish cards on _foundation_ without limit turn.

    _row_
      Pile 9 horz N. Init deal [1, 2, 3, 4, 5, 6, 7, 8, 9] card. Build
      down in rank by alt color. Play seq. Base KING.

    _talon_
      Pile 1 SE. Deal 3 card on _waste_.

    _waste_
      Pile 1 W _talon_. Build none. Play top.

    _foundation_
      Pile 8 horz S. Build up in rank by same suit. Play top.
    ------
    :cvar Layout _layout_: layout.HarpLayout
    :cvar Stack _talon_: stack.WasteTalon (max_rounds=INFINITE,
       num_deal=3)
    :cvar Stack _waste_: stack.WasteStack
    :cvar Stack _foundation_: stack.SS_Foundation
    :cvar Stack _row_: stack.AC_RowStack (base_rank=KING)
    :cvar Hint _hint_: hint.DefaultHint
    """
    __info__ = dict(id=28, name='Double Klondike by Threes',
                    game_type=GT.KLONDIKE, decks=2, redeals=cs.INFINITE,
                    skill_level=SL.MOSTLY_LUCK, version='2.90',
                    altnames=('Klondike (2 Decks, 3 Card Deal)',))
    __author__ = 'Markus Oberhumer'
    __version__ = 7.70

    _talon_ = Wrap(stack.WasteTalon, max_rounds=cs.INFINITE, num_deal=3)


class TripleKlondike(DoubleKlondike):
    """
    Finish cards on _foundation_ without limit turn.

    _row_
      Pile 13 horz N. Init deal [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
      card. Build down in rank by alt color. Play seq. Base KING.

    _talon_
      Pile 1 SE. Deal 1 card on _waste_.

    _waste_
      Pile 1 W _talon_. Build none. Play top.

    _foundation_
      Pile 12 horz S. Build up in rank by same suit. Play top.
    ------
    :cvar Layout _layout_: layout.HarpLayout
    :cvar Stack _talon_: stack.WasteTalon (max_rounds=INFINITE)
    :cvar Stack _waste_: stack.WasteStack
    :cvar Stack _foundation_: stack.SS_Foundation
    :cvar Stack _row_: stack.AC_RowStack (base_rank=KING)
    :cvar Hint _hint_: hint.DefaultHint
    """
    __info__ = dict(id=273, name='Triple Klondike', game_type=GT.KLONDIKE,
                    decks=3, redeals=cs.INFINITE, skill_level=SL.BALANCED,
                    version='0.80fc', altnames=('Klondike (3 Decks)',))
    __author__ = 'Skomoroh'
    __version__ = 7.70

    def _create_game(self, **kw):
        kw.setdefault('rows', 13)
        return super(TripleKlondike, self)._create_game(**kw)


class TripleKlondikeByThrees(TripleKlondike):
    """
    Finish cards on _foundation_ without limit turn.

    _row_
      Pile 13 horz N. Init deal [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
      card. Build down in rank by alt color. Play seq. Base KING.

    _talon_
      Pile 1 SE. Deal 3 card on _waste_.

    _waste_
      Pile 1 W _talon_. Build none. Play top.

    _foundation_
      Pile 12 horz S. Build up in rank by same suit. Play top.
    ------
    :cvar Layout _layout_: layout.HarpLayout
    :cvar Stack _talon_: stack.WasteTalon (max_rounds=INFINITE,
      num_deal=3)
    :cvar Stack _waste_: stack.WasteStack
    :cvar Stack _foundation_: stack.SS_Foundation
    :cvar Stack _row_: stack.AC_RowStack (base_rank=KING)
    :cvar Hint _hint_: hint.DefaultHint
    """
    __info__ = dict(id=274, name='Triple Klondike by Threes',
                    game_type=GT.KLONDIKE, decks=3, redeals=cs.INFINITE,
                    skill_level=SL.MOSTLY_LUCK, version='0.80fc',
                    altnames=('Klondike (3 Decks, 3 Card Deal)',))
    __author__ = 'Skomoroh'
    __version__ = 7.70

    _talon_ = Wrap(stack.WasteTalon, max_rounds=cs.INFINITE, num_deal=3)


class Gargantua(DoubleKlondike):
    """
    Finish cards on _foundation_ within 2 turn.

    _row_
      Pile 9 horz N. Init deal [1, 2, 3, 4, 5, 6, 7, 8, 9] card. Build
      down in rank by alt color. Play seq. Base KING.

    _talon_
      Pile 1 SE. Deal 1 card on _waste_.

    _waste_
      Pile 1 W _talon_. Build none. Play top.

    _foundation_
      Pile 8 horz S. Build up in rank by same suit. Play top.
    ------
    :cvar Layout _layout_: layout.HarpLayout
    :cvar Stack _talon_: stack.WasteTalon (max_rounds=2)
    :cvar Stack _waste_: stack.WasteStack
    :cvar Stack _foundation_: stack.SS_Foundation
    :cvar Stack _row_: stack.AC_RowStack (base_rank=KING)
    :cvar Hint _hint_: hint.DefaultHint
    """
    __info__ = dict(id=25, name='Gargantua', game_type=GT.KLONDIKE, decks=2,
                    redeals=1, skill_level=SL.BALANCED, version='2.90')
    __author__ = 'Markus Oberhumer'
    __credits__ = ['Albert Morehead', 'Geoffrey Mott-Smith']
    __version__ = 7.70

    _talon_ = Wrap(stack.WasteTalon, max_rounds=2)


class Steps(Gargantua):
    """
    Finish cards on _foundation_ within 2 turn.

    _row_
      Pile 7 horz N. Init deal [1, 2, 3, 4, 5, 6, 7] card. Build
      down in rank by alt color. Play seq.

    _talon_
      Pile 1 SE. Deal 1 card on _waste_.

    _waste_
      Pile 1 W _talon_. Build none. Play top.

    _foundation_
      Pile 8 horz S. Build up in rank by same suit. Play top.
    ------
    :cvar Layout _layout_: layout.HarpLayout
    :cvar Stack _talon_: stack.WasteTalon (max_rounds=2)
    :cvar Stack _waste_: stack.WasteStack
    :cvar Stack _foundation_: stack.SS_Foundation
    :cvar Stack _row_: stack.AC_RowStack
    :cvar Hint _hint_: hint.DefaultHint
    """
    __info__ = dict(id=51, name='Steps', game_type=GT.KLONDIKE, decks=2,
                    redeals=1, skill_level=SL.BALANCED, version='3.00')
    __author__ = 'Markus Oberhumer'
    __version__ = 7.70

    _row_ = stack.AC_RowStack

    def _create_game(self, **kw):
        kw.setdefault('rows', 7)
        return super(Steps, self)._create_game(**kw)


class Pantagruel(DoubleKlondike):
    """
    Finish cards on _foundation_ within 1 turn.

    _row_
      Pile 9 horz N. Init deal [1, 2, 3, 4, 5, 6, 7, 8, 9] card. Build
      down in rank by alt color. Play seq.

    _talon_
      Pile 1 SE. Deal 1 card on _waste_.

    _waste_
      Pile 1 W _talon_. Build none. Play top.

    _foundation_
      Pile 8 horz S. Build up in rank by same suit. Play top.
    ------
    :cvar Layout _layout_: layout.HarpLayout
    :cvar Stack _talon_: stack.WasteTalon
    :cvar Stack _waste_: stack.WasteStack
    :cvar Stack _foundation_: stack.SS_Foundation
    :cvar Stack _row_: stack.AC_RowStack
    :cvar Hint _hint_: hint.DefaultHint
    """
    __info__ = dict(id=591, name='Pantagruel', game_type=GT.KLONDIKE, decks=2,
                    skill_level=SL.BALANCED, version='0.93fc')
    __author__ = 'Skomoroh'
    __version__ = 7.70

    _talon_ = stack.WasteTalon
    _row_ = stack.AC_RowStack


class BigHarp(Pantagruel):
    """
    Finish cards on _foundation_ within 1 turn.

    _row_
      Pile 10 horz N. Init deal [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] card. Build
      down in rank by alt color. Play seq.

    _talon_
      Pile 1 SE. Deal 1 card on _waste_.

    _waste_
      Pile 1 W _talon_. Build none. Play top.

    _foundation_
      Pile 8 horz S. Build up in rank by same suit. Play top.
    ------
    :cvar Layout _layout_: layout.HarpLayout
    :cvar Stack _talon_: stack.WasteTalon
    :cvar Stack _waste_: stack.WasteStack
    :cvar Stack _foundation_: stack.SS_Foundation
    :cvar Stack _row_: stack.AC_RowStack
    :cvar Hint _hint_: hint.DefaultHint
    """
    __info__ = dict(id=15, name='Big Harp', game_type=(GT.KLONDIKE |
                    GT.ATARI), decks=2, skill_level=SL.BALANCED,
                    version='1.10',
                    altnames=('Die Große Harfe', 'Harp (2 Decks)',))
    __author__ = 'Markus Oberhumer'
    __version__ = 7.70

    def _create_game(self, **kw):
        kw.setdefault('rows', 10)
        return super(BigHarp, self)._create_game(**kw)

    def _start(self, flip=False, reverse=True, **kw):
        """
        Deal initial cards for new game.
          - s[rows] LEN..1 ea top.

        .. \_start([flip=False, reverse=True]) -> None
        """
        for i in range(1, len(self.s['rows'])):
            self.s['talon'].dealRow(rows=self.s['rows'][:i], flip=flip,
                                    reverse=reverse, frames=0)
        self.s['talon'].dealRow(reverse=reverse)


class ChineseKlondike(DoubleKlondike):
    """
    Finish cards on _foundation_ without limit turn.

    _row_
      Pile 12 horz N. Init deal [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] card.
      Build down in rank by alt suit. Play seq. Base KING.

    _talon_
      Pile 1 SE. Deal 3 card on _waste_.

    _waste_
      Pile 1 W _talon_. Build none. Play top.

    _foundation_
      Pile 9 horz S. Build up in rank by same suit. Play top.
    ------
    :cvar Layout _layout_: layout.HarpLayout
    :cvar Stack _talon_: stack.WasteTalon (max_rounds=INFINITE,
       num_deal=3)
    :cvar Stack _waste_: stack.WasteStack
    :cvar Stack _foundation_: stack.SS_Foundation
    :cvar Stack _row_: stack.BO_RowStack (base_rank=KING)
    :cvar Hint _hint_: hint.DefaultHint
    """
    __info__ = dict(id=590, name='Chinese Klondike', game_type=GT.KLONDIKE,
                    decks=3, redeals=cs.INFINITE, skill_level=SL.BALANCED,
                    suits=tuple(range(3)), version='0.93fc')
    __author__ = 'Skomoroh'
    __version__ = 7.70

    _row_ = Wrap(stack.BO_RowStack, base_rank=cs.KING)

    def _create_game(self, **kw):
        kw.setdefault('rows', 12)
        return super(ChineseKlondike, self)._create_game(**kw)


class LadyJane(DoubleKlondike):
    """
    Finish cards on _foundation_ within 2 turn.

    _row_
      Pile 9 horz N. Init deal [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] card. Build
      down in rank alone. Play seq by same suit.

    _talon_
      Pile 1 SE. Deal 1 card on _waste_.

    _waste_
      Pile 1 W _talon_. Build none. Play top.

    _foundation_
      Pile 8 horz S. Build up in rank by same suit. Play top.
    ------
    :cvar Layout _layout_: layout.HarpLayout
    :cvar Stack _talon_: stack.WasteTalon (max_rounds=2, num_deal=3)
    :cvar Stack _waste_: stack.WasteStack
    :cvar Stack _foundation_: stack.SS_Foundation
    :cvar Stack _row_: stack.SS_RK__RowStack
    :cvar Hint _hint_: spider.Hint
    """
    __info__ = dict(id=495, name='Lady Jane', game_type=GT.KLONDIKE, decks=2,
                    redeals=1, skill_level=SL.BALANCED, version='0.93fc')
    __author__ = 'Skomoroh'
    __credits__ = ['Thomas Warfield']
    __version__ = 7.70

    _talon_ = Wrap(stack.WasteTalon, max_rounds=2, num_deal=3)
    _row_ = spider.SS_RK_RowStack
    _hint_ = spider.Hint

    def _create_game(self, **kw):
        kw.setdefault('rows', 10)
        return super(LadyJane, self)._create_game(**kw)

    def _start(self, **kw):
        """
        Deal initial cards for new game.
          - s[rows] 1..LEN ea up.

        .. \_start([flip=True, reverse=True]) -> None
        """
        kw.setdefault('flip', True)
        return super(LadyJane, self)._start(**kw)

    _quickplay_ = quickplay.Spider


class Brush(LadyJane):
    """
    Finish cards on _foundation_ within 2 turn.

    _row_
      Pile 9 horz S _foundation_. Init deal 4 open card. Build
      down in rank alone. Play seq by same suit. Drop full seq by same suit on
      _foundation_

    _talon_
      Pile 1 SE. Deal 1 card on _waste_.

    _waste_
      Pile 1 W _talon_. Build none. Play top.

    _foundation_
      Pile 8 horz S. Build none. Play none.
    ------
    :cvar Layout _layout_: layout.KlondikeLayout
    :cvar Stack _talon_: stack.WasteTalon
    :cvar Stack _waste_: stack.WasteStack
    :cvar Stack _foundation_: stack.SS_Foundation
    :cvar Stack _row_: stack.SS_RK__RowStack
    :cvar Hint _hint_: spider.Hint
    """
    __info__ = dict(id=689, name='Brush', game_type=(GT.SPIDER | GT.ORIGINAL),
                    decks=2, skill_level=SL.MOSTLY_SKILL,
                    version='1.00fc')
    __author__ = 'Skomoroh'
    __version__ = 7.70

    _layout_ = layout.KlondikeLayout
    _talon_ = stack.WasteTalon
    _foundation_ = spider.SS_Foundation
    _row_ = spider.DropSS_RK_RowStack

    def _start(self, rows=4, flip=True, **kw):
        """
        Deal initial cards for new game.
          - s[rows] 4 ea up.

        .. \_start([rows=4, flip=True]) -> None
        """
        for i in range(rows - 1):
            self.s['talon'].dealRow(flip=flip, frames=0)
        self.s['talon'].dealRow()


class Arabella(LadyJane):
    """
    Finish cards on _foundation_ within 1 turn.

    _row_
      Pile 9 horz N. Init deal [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
      card. Build down in rank alone. Play seq by same suit. Base KING.

    _talon_
      Pile 1 SE. Deal 1 card on _waste_.

    _waste_
      Pile 1 W _talon_. Build none. Play top.

    _foundation_
      Pile 8 horz S. Build up in rank by same suit. Play top.
    ------
    :cvar Layout _layout_: layout.HarpLayout
    :cvar Stack _talon_: stack.WasteTalon
    :cvar Stack _waste_: stack.WasteStack
    :cvar Stack _foundation_: stack.SS_Foundation
    :cvar Stack _row_: stack.SS_RK__RowStack
    :cvar Hint _hint_: spider.Hint
    """
    __info__ = dict(id=497, name='Arabella', game_type=GT.KLONDIKE, decks=3,
                    skill_level=SL.BALANCED, version='0.92fc')
    __author__ = 'Skomoroh'
    __credits__ = ['Thomas Warfield']
    __version__ = 7.70

    _talon_ = stack.WasteTalon
    _row_ = Wrap(spider.SS_RK_RowStack, base_rank=cs.KING)

    def _create_game(self, **kw):
        kwdefault(kw, rows=13, playcards=24)
        return super(Arabella, self)._create_game(**kw)


class Inquisitor(DoubleKlondike):
    """
    Finish cards on _foundation_ within 3 turn.

    _row_
      Pile 9 horz N. Init deal [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] open card.
      Build down in rank by same suit. Play seq.

    _talon_
      Pile 1 SE. Deal 3 card on _waste_.

    _waste_
      Pile 1 W _talon_. Build none. Play top.

    _foundation_
      Pile 8 horz S. Build up in rank by same suit. Play top.
    ------
    :cvar Layout _layout_: layout.HarpLayout
    :cvar Stack _talon_: stack.WasteTalon (max_rounds=3, num_deal=3)
    :cvar Stack _waste_: stack.WasteStack
    :cvar Stack _foundation_: stack.SS_Foundation
    :cvar Stack _row_: stack.SS_RowStack
    :cvar Hint _hint_: hint.DefaultHint
    """
    __info__ = dict(id=496, name='Inquisitor', game_type=GT.KLONDIKE,
                    decks=2, redeals=2, skill_level=SL.BALANCED,
                    version='0.93fc')
    __author__ = 'Skomoroh'
    __credits__ = ['Thomas Warfield']
    __version__ = 7.70

    _talon_ = Wrap(stack.WasteTalon, max_rounds=3, num_deal=3)
    _row_ = stack.SS_RowStack

    def _create_game(self, **kw):
        kw.setdefault('rows', 10)
        return super(Inquisitor, self)._create_game(**kw)

    def _start(self, **kw):
        """
        Deal initial cards for new game.
          - s[rows] 1..LEN ea up.

        .. \_start([flip=True, reverse=True]) -> None
        """
        kw.setdefault('flip', True)
        return super(Inquisitor, self)._start(**kw)


class BigDeal(DoubleKlondike):
    """
    Finish cards on _foundation_ within 2 turn.

    :CVariables:
      _layout_ : pysollib.layout.Layout
        .. pysollib.layouts.gypsy.GypsyLayout
        - row [9 horz NW, vert offset]
        - talon [1 SE, no offset]
        - waste [1 W talon, no offset]
        - foundation [16 over 4 E, no offset]

    _row_
      Init deal [1..12] card.
      Build down in rank by alt color. Play seq. Base KING.

    _talon_
      Deal 1 card on _waste_.

    _waste_
       Build none. Play top.

    _foundation_
      Build up in rank by same suit. Play top.
    ------
    :cvar Stack _talon_: stack.WasteTalon (max_rounds=2)
    :cvar Stack _waste_: stack.WasteStack
    :cvar Stack _foundation_: stack.SS_Foundation
    :cvar Stack _row_: stack.AC_RowStack (base_rank=KING)
    :cvar Hint _hint_: hint.DefaultHint
    """
    __info__ = dict(id=545, name='Big Deal', game_type=(GT.KLONDIKE |
                    GT.ORIGINAL), decks=4, redeals=1, skill_level=SL.BALANCED,
                    version='0.93fc')
    __author__ = 'Skomoroh'
    __version__ = 7.70

    _layout_ = GypsyLayout.GypsyLayout
    _talon_ = Wrap(stack.WasteTalon, max_rounds=2)

    def _create_game(self, **kw):
        kwdefault(kw, rows=12, align=layout.LEFT)
        return super(BigDeal, self)._create_game(**kw)


class Delivery(BigDeal):
    """
    Finish cards on _foundation_ within 1 turn.

    _row_
      Pile 9 horz N. Init deal 3 open card. Build down in rank by alt color.
      Play top.

    _talon_
      Pile 1 SW. Deal 1 card on _waste_.

    _waste_
      Pile 1 E _talon_. Build none. Play top.

    _foundation_
      Pile 16 over 2 col E. Build up in rank by same suit. Play top.
    ------
    :cvar Layout _layout_: layout.HarpLayout
    :cvar Stack _talon_: stack.WasteTalon
    :cvar Stack _waste_: stack.WasteStack
    :cvar Stack _foundation_: stack.SS_Foundation
    :cvar Stack _row_: stack.SS_RowStack (max_move=1)
    :cvar Hint _hint_: hint.CautiousDefaultHint
    """
    __info__ = dict(id=562, name='Delivery', game_type=(GT.FORTY_THIEVES |
                    GT.ORIGINAL), decks=4, skill_level=SL.BALANCED,
                    version='0.93fc')
    __author__ = 'Skomoroh'
    __version__ = 7.70

    _talon_ = stack.WasteTalon
    _row_ = Wrap(stack.SS_RowStack, max_move=1)
    _hint_ = CautiousDefaultHint

    def _create_game(self, **kw):
        kwdefault(kw, rows=12, offset=True)
        return super(Delivery, self)._create_game(**kw)

    def _start(self, rows=3, flip=True, **kw):
        """
        Deal initial cards for new game.
          - s[rows] 3 ea up.

        .. \_start([flip=True]) -> None
        """
        for i in range(rows - 1):
            self.s['talon'].dealRow(frames=0)
        self.s['talon'].dealRow()


class DoubleKingsley(DoubleKlondike):
    """
    Finish cards on _foundation_ within 1 turn.

    _row_
      Pile 9 horz N. Init deal [1, 2, 3, 4, 5, 6, 7, 8, 9] card. Build up in
      rank by alt color. Play seq. Base ACE.

    _talon_
      Pile 1 SE. Deal 1 card on _waste_.

    _waste_
      Pile 1 W _talon_. Build none. Play top.

    _foundation_
      Pile 8 horz S. Build down in rank by same suit. Play top.
    ------
    :cvar Layout _layout_: layout.HarpLayout
    :cvar Stack _talon_: stack.WasteTalon
    :cvar Stack _waste_: stack.WasteStack
    :cvar Stack _foundation_: stack.SS_Foundation (base_rank=KING,
      dir=-1)
    :cvar Stack _row_: stack.AC_RowStack (base_rank=ACE, dir=1)
    :cvar Hint _hint_: hint.DefaultHint
    """
    __info__ = dict(id=668, name='Double Kingsley', game_type=GT.KLONDIKE,
                    decks=2, skill_level=SL.BALANCED,
                    altnames=('Kingsley (2 Decks)',), version='0.94fc')
    __author__ = 'Skomoroh'
    __version__ = 7.70

    _talon_ = stack.WasteTalon
    _foundation_ = Wrap(stack.SS_Foundation, base_rank=cs.KING, dir=-1)
    _row_ = Wrap(stack.AC_RowStack, base_rank=cs.ACE, dir=1)


class ThievesOfEgypt(DoubleKlondike):
    """
    Finish cards on _foundation_ within 2 turn.

    _row_
      Pile 10 horz N. Init deal [1, 2, 3, 4, 5, 5, 4, 3, 2, 1] card. Build
      down in rank by alt color. Play seq. Base KING.

    _talon_
      Pile 1 SE. Deal 1 card on _waste_.

    _waste_
      Pile 1 W _talon_. Build none. Play top.

    _foundation_
      Pile 8 horz S. Build up in rank by same suit. Play top.
    ------
    :cvar Layout _layout_: layout.KlondikeLayout
    :cvar Stack _talon_: stack.WasteTalon (max_rounds=2)
    :cvar Stack _waste_: stack.WasteStack
    :cvar Stack _foundation_: stack.SS_Foundation
    :cvar Stack _row_: stack.AC_RowStack (base_rank=KING)
    :cvar Hint _hint_: hint.DefaultHint
    """
    __info__ = dict(id=678, name='Thieves of Egypt', game_type=GT.KLONDIKE,
                    decks=2, redeals=1, skill_level=SL.BALANCED,
                    version='1.00fc')
    __author__ = 'Skomoroh'
    __version__ = 7.70

    _layout_ = layout.KlondikeLayout
    _talon_ = Wrap(stack.WasteTalon, max_rounds=2)

    def _create_game(self, **kw):
        kw.setdefault('rows', 10)
        return super(ThievesOfEgypt, self)._create_game(**kw)

    def _start(self, flip=True, **kw):
        """
        Deal initial cards for new game.
          - s[rows] 1..LEN // 2..1 ea up.

        .. \_start([flip=True]) -> None
        """
        for i in range(1, len(self.s['rows'])  // 2):
            self.s['talon'].dealRow(rows=[self.s['rows'][i:-i]], flip=flip,
                                    frames=0)
        self.s['talon'].dealRow()

PROVIDES = [DoubleKlondike, DoubleKlondikeByThrees, Gargantua, BigHarp, Steps,
            TripleKlondike, TripleKlondikeByThrees, LadyJane, Inquisitor,
            Arabella, BigDeal, Delivery, ChineseKlondike, Pantagruel,
            DoubleKingsley, ThievesOfEgypt, Brush]